-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add Scala 2 macro compat to Scala2Compat mode #8199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
7f7ff4e
to
75f0588
Compare
What is the purpose of this change ? |
Co-Authored-By: Guillaume Martres <smarter@ubuntu.com>
This would be so that an artifact can publish exclusively for dotc, but still be consumed from scala 2 |
Given this limitation:
It seems like very few macros could actually take advantage of this. Wouldn't it be much simpler to get the build tool to put classfiles compiled with Scala 2 in Dotty artifacts instead ? |
so scala 2 compiled macro is on classpath to dotc, symbol to scala 2 macro impl is on the rhs of a macro def in dotty, and then TASTy links to that symbol? |
I don't understand what this would allow exactly. Here's a quick sketch of what I have in mind:
This allow presenting the same user API for Scala 2 and Scala 3 macros, and does not require any change to dotty or tasty. |
Alternatively, we could also output the classfiles from .scala2 files next to the regular classfiles, this would not allow the same user API for Scala 2 and 3 (the class names would have to be different) but would be simpler to implement, and would allow using scala 2 files in dotty projects for other reasons. This should be implementable in |
Yeah I think the classfiles should live next to each other, with the Scala 2 ones being under Scala 2's current schema, and the new Scala 3 ones adding some variant (let's say It would be good to get a survey of how many macros out there are using Lastly, the strategy of using nsc after dotc requires depending/using nsc, which includes paying the price of spinning it up. It would be nice to create a library jar in 1 dotc run only. |
If a Scala 2 macro uses
With this architecture, there is no need to teach either sbt or scalac/dotc to deal with weird classfiles (side classfiles or multi-jar whatever). |
If I understand you correctly, you can't make that dependency without teaching sbt. |
Hum, it should be a straightforward dependency between configurations, like there already exist between |
Yeah, you can't redefine the hierarchy of Configurations, even just appending. Some users want to redefine IntegrationTest to extend Test, but can't. |
Well ... in the worst case one can use a separate project then, instead of a configuration. |
I've always assumed there'd be bits and bobs to change here and there in the toolchain to facilitate Scala 3, so I'm not concerned about that. But, ideally, I'd still prefer not warming up two compilers for 1 jar. |
This was added in #8811 |
Suport for
Current limitations
reify { }
andq"..."
)